function MRViewerClass()
{
  this.pageCount = 1;
  this.url0 = "";
  this.url = "";
  this.reportCenter = "";
  this.reportFile = "";
  this.pageNo = 0;
  this.refreshFlag = false;
  
  this.simple = false;
  this.height = "100%";
  this.width = "100%";
  this.indexStr = "";
  this.variableStr = "";
  this.getSimple=doGetSimple;
  this.setSimple=doSetSimple;

  this.Print=doPrint;
  this.SetIndex=doSetIndex;
  this.SetVariable=doSetVariable;
  this.Preview=doPreview;
  this.FirstPage=doFirstPage;
  this.PriorPage=doPriorPage;
  this.NextPage=doNextPage;
  this.LastPage=doLastPage;
  this.GoPage=doGoPage;
  this.SetPage=doSetPage;
  this.ExportFile=doExport;
  this.Refresh=doRefresh;
  this.print=doPrint;
  this.setIndex=doSetIndex;
  this.setVariable=doSetVariable;
  this.preview=doPreview;
  this.firstPage=doFirstPage;
  this.priorPage=doPriorPage;
  this.nextPage=doNextPage;
  this.lastPage=doLastPage;
  this.goPage=doGoPage;
  this.setPage=doSetPage;
  this.exportFile=doExport;
  this.refresh=doRefresh;
}
function doSetSimple(val)
{
  this.simple=val;
  if(this.simple){
    document.all("MRVIEWER_TOOLBAR").style.display="none";
	MRVIEWER_IFRAME.frameborder=0;
  }else{
    document.all("MRVIEWER_TOOLBAR").style.display="block";
	MRVIEWER_IFRAME.frameborder=1;
  }
}
function doGetSimple()
{
  return this.simple;
}
function doSetIndex(dsName, fields)
{
  if(this.indexStr!="")this.indexStr+=";";
  this.indexStr+="\""+dsName+"="+fields+"\"";
}
function doSetVariable(varName, val)
{
  if(this.variableStr!="")this.variableStr+=";";
  this.variableStr+="\""+varName+"="+val+"\"";
}
function doFirstPage()
{
  this.GoPage(0);
}
function doPriorPage()
{
  this.GoPage(this.pageNo-1);
}
function doNextPage()
{
  this.GoPage(this.pageNo+1);
}
function doLastPage()
{
  this.GoPage(this.pageCount);
}
function makeNum(num,dig)
{
  if(num==1)return "";
  var str = "00000000"+num;
  return str.substr(str.length-dig,dig);
}
function doGoPage(pNo)
{
  if(isNaN(pNo))return;
  this.pageCount=document.all("MRVIEWER_edtPageCount").innerText;
  if(pNo<-1)pNo=0;
  if(pNo>=this.pageCount)pNo=this.pageCount-1;
  this.pageNo = pNo<0?0:pNo;
  MRVIEWER_IFRAME.navigate(this.url0+makeNum(this.pageNo+1,4)+".htm");
  document.all("MRVIEWER_edtPageNo").value=this.pageNo+1;
}
function doSetPage(pg)
{
  var key = window.event.keyCode;
  if (key==13){
    if(parseInt(pg)==isNaN)return;
    this.GoPage(parseInt(pg)-1);
  }
}
function sw(isPrinted)
{
  var ctn = MRVIEWER_IFRAME.document.all("REPORT_CONTAINER");
  var ctrl = MRVIEWER_IFRAME.document.all("REPORT_CONTROL");
  ctn.style.top=isPrinted?0:10;  
  ctn.style.left=isPrinted?0:10;  
  for(i=0;i<ctrl.length;i++)
    ctrl[i].style.display=isPrinted?"none":"";
  MRVIEWER_IFRAME.document.body.bgColor=isPrinted?"#FFFFFF":"#808080";
}
function doPrint()
{
  MRVIEWER_IFRAME.focus();
  MRVIEWER_IFRAME.document.execCommand("Print");
}
function doPreview()
{
    var str=this.reportCenter+"?EXPORT_FILE=HTM&EXPORT_PATH="+this.url;
    str+="&REPORT_FILE="+this.reportFile;
    str+="&INDEX_STR="+this.indexStr+"&VARIABLE_STR="+this.variableStr;
    this.indexStr="";
    this.variableStr="";
    //MRVIEWER_IFRAME_EXPORT.location.replace(str);
    MRVIEWER_IFRAME_EXPORT.location.replace(this.url);
}
function doExport(vType)
{
    var exportType = "";
	if(vType==-1){
      exportType=document.all("MRVIEWER_selExport").options[document.all("MRVIEWER_selExport").selectedIndex].text;
	  if(exportType=="")return;
	 }else
	   exportType = vType;
    MRVIEWER_IFRAME_EXPORT.location.replace(this.reportCenter+"?EXPORT_FILE="+exportType+"&EXPORT_PATH="+this.url);
}
function doRefresh()
{
	alert("test");
    var str = this.reportCenter+"?DO_REFRESH=TRUE&EXPORT_PATH="+this.url;
    MRVIEWER_IFRAME_EXPORT.location.reload();
    this.refreshFlag=true;
}
function mover(obj)
{
   obj.style.borderColor="#FFFFFF #009999 #009999 #FFFFFF";
}
function mout(obj)
{
   obj.style.borderColor="#d4d0c8 #d4d0c8 #d4d0c8 #d4d0c8";
}
function mdown(obj)
{
   obj.style.borderColor="#009999 #FFFFFF #FFFFFF #009999";
}
function mup(obj)
{
   obj.style.borderColor="#FFFFFF #009999 #009999 #FFFFFF";
}
